//
//  TyrionApi.swift
//  Pods
//
//  Created by eme on 2017/4/1.
//
//
import Foundation
import Alamofire
import ModelProtocol
import NetWorkCore
import UtilCore

/*
 owner:cy
 update:2017年04月01日17:23:11
 info: 地址管理 api
 
 */

public enum TyrionApi{
    /// 收货地址列表
    case getAddressList
    ///获取收货地址对象(编辑or修改时)
    case changeAddress(addid:String)
    ///修改或添加新的地址
    case changeAddressOrAddNewAddress(message:String)
     ///删除收货地址
    case deleteShopAddress(addid:String)
}
extension TyrionApi: TargetType {
    //设置请求路径
    public var path: String {
        switch self {
        case .getAddressList:
            return "/glShopAddress/a/list.json"                             ///收货地址列表
        case .changeAddress:
            return "/glShopAddress/a/shopaddress.json"                      ///获取收货地址对象(编辑or修改时)
        case .changeAddressOrAddNewAddress:
            return "/glShopAddress/a/save.json"
        case .deleteShopAddress(_):
            return "/glShopAddress/a/del.json"
        }
    }
    //设置请求方式 get post等
    public var method: HTTPMethod {
        switch self {
        default :
            return .post
        }
    }
    /// 设置请求参数
    public var parameters: Parameters? {
        switch self {
        case let .changeAddress(addid):
            return ["addid":addid]
        case let .changeAddressOrAddNewAddress(message):
            return ["glShopAddress":message]
        case let .deleteShopAddress(addid):
            return ["addid":addid]
        default :
            return nil
        }
    }
    
}
